/*
 *
 * Copyright (C) 2012 Walter Lütgenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package offset.nodes.client.editor;

import java.awt.CardLayout;
import java.awt.Container;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.net.URI;

import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.JToolBar.Separator;
import javax.swing.JTree;
import javax.swing.KeyStroke;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import javax.swing.text.Element;
import javax.swing.text.html.HTML;

import offset.nodes.client.editor.controller.CharacterActions;
import offset.nodes.client.editor.controller.component.ComponentActions;
import offset.nodes.client.editor.controller.EditorActions;
import offset.nodes.client.editor.controller.EditorKit;
import offset.nodes.client.editor.controller.FileActions;
import offset.nodes.client.editor.controller.HyperlinkActions;
import offset.nodes.client.editor.controller.ImageActions;
import offset.nodes.client.editor.controller.ListActions;
import offset.nodes.client.editor.controller.ParagraphActions;
import offset.nodes.client.editor.controller.TableActions;
import offset.nodes.client.editor.controller.UndoActions;
import offset.nodes.client.editor.controller.ViewActions;
import offset.nodes.client.editor.model.DocumentContext;
import offset.nodes.client.editor.model.EditorModel;
import offset.nodes.client.editor.model.HeadingTree;
import offset.nodes.client.editor.model.StructureTree;
import offset.nodes.client.editor.view.PopupTree.NodePopup;
import offset.nodes.client.editor.view.UserCaretListener;
import offset.nodes.client.model.CommentedUserRequest;
import offset.nodes.client.view.BaseApplet;
import offset.nodes.client.view.component.ComponentDialog;
import offset.nodes.client.view.Result;
import offset.nodes.client.view.component.ComponentContainer;
import offset.nodes.client.view.component.ComponentEditor;

/**
 *
 * @author  Walter Lütgenau
 */
public class Editor extends BaseApplet implements ComponentDialog, ComponentEditor {

    static HashMap<JEditorPane,Editor> editors = new HashMap<JEditorPane,Editor>();
    JFileChooser chooser;
    HeadingTree heading;
    StructureTree structure;
    boolean debug = false;
    String base = "file:/";
    public static final int MODE_PAGE_EDITOR = 1;
    /*
    public static final int MODE_TEMPLATE_EDITOR = 2;
    public static final int MODE_VIRTUAL_PAGE_DATA_EDITOR = 3;*/
    public static final int MODE_LOCAL_PAGE_EDITOR = 4;
    /*public static final int MODE_VIRTUAL_PAGE_EDITOR = 5;
    public static final int MODE_VIRTUAL_PAGE_INSTANCE_EDITOR = 6;*/
    protected int mode = MODE_PAGE_EDITOR;

    protected Result result = new Result();
    protected Container container = null;

    // properties
    public static final String PROP_DOCUMENT_PATH = "documentPath";
    public static final String PROP_DOCUMENT_URL = "documentUrl";
    public static final String PROP_UPLOAD_TO = "uploadTo";
    public static final String PROP_SECONDARY_QUERIES = "secondaryQueries";
    public static final String PROP_SELECT_QUERIES = "selectQueries";
    public static final String PROP_NODE_TYPES = "nodeTypes";
    public static final String PROP_INSTANCE_PATH = "instancePath";
    public static final String PROP_VIRTUAL_BLOCKS = "virtualBlocks";
    public static final String PROP_WORKFLOW_PROPERTIES = "workflowProperties";
    public static final String PROP_TEMPLATE_NODE_PATH = "templatePath";
    public static final String PROP_RETURN_URL = "returnUrl";
    public static final String PROP_PARENT_PATH = "parentPath";
    public static final String PROP_EXTERNAL_TEMPLATES = "externalTemplates"; // List<String>

    protected HashMap properties = new HashMap();

    protected List<UserCaretListener> caretListeners = new LinkedList<UserCaretListener>();
    protected UndoActions.EditorActionUndoManager undoManager;;
    protected UndoActions.UndoAction undoAction;
    protected UndoActions.RedoAction redoAction;;
    protected UndoActions.EditorUndoableEditListener undoableEditListener;

    // component members
    protected Action backupAction = null;
    protected Action restoreAction = null;
    
    protected ComponentContainer componentContainer = null;    

    public ComponentContainer getComponentContainer() {
        return componentContainer;
    }
    
   /**
     * Set the dialog mode. In dialog mode, save and exit
     * will be controlled from outside.
     *
     * @param dialogMode
     */
    @Override
    public void setContainer(ComponentContainer container) {
        this.componentContainer = container;
        if (componentContainer != null) {
            getFileMenu().setVisible(false);
            getSaveServerButton().setVisible(false);
            getSaveServerCommentButton().setVisible(false);
            getExitButton().setVisible(false);
            backupAction = new FileActions.BackupAction(this); 
            backupAction.actionPerformed(null);
            restoreAction = new FileActions.RestoreAction(this);

            EditorKit kit = (EditorKit) getBrowserPane().getEditorKit();
            kit.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), new FileActions.ContainerOkAction(this));
        } else {
            getFileMenu().setVisible(true);
            getSaveServerButton().setVisible(true);
            getExitButton().setVisible(true);
        }
    }    
    
    /**
     * The ok button of the outside dialog has been pressed.
     * Save the result to the server.
     */
    @Override
    public void ok() {
        if (backupAction != null)
            backupAction.actionPerformed(null);
    }

    /**
     * The cancel button of the outside dialog has been pressed,
     * cancel.
     */
    @Override
    public void cancel() {
        if (restoreAction != null)
            restoreAction.actionPerformed(null);
    }

    /**
     * Do not save state, just finish.
     */
     @Override
    public void exit() {
        getExitButton().getAction().actionPerformed(null);
    }

     /**
      * Save state to server and finish.
      */
    @Override
    public void save(CommentedUserRequest comment) {
        if (comment != null)
            ((FileActions.SaveServerCommentAction) getSaveServerCommentButton().getAction()).runAction(comment);
        else
            ((FileActions.SaveServerAction) getSaveServerButton().getAction()).runAction();
    }

    /**
     * Return the HTML describing the editor state.
     * 
     * @return 
     */
    @Override
    public String getHtml() {
        if (result.getValue() == null || !(result.getValue() instanceof String))
            return null;
        return (String) result.getValue();
    }
    
    /**
     * Return the main pane.
     * 
     * @return the browser pane
     */
    @Override
    public JComponent getMainPane() {
        return getBrowserPane();
    }
    
    /**
     * Return the tree pane
     * 
     * @return the tree pane, with all views
     */
    @Override
    public JPanel getTreePane() {
        return getTreePanel();
    }

    /**
     * Return the components of the editor pane.
     * 
     * @return the components
     */
    @Override
    public Collection<ComponentEditor> getComponentEditors() {
        if (!(browserPane.getEditorKit() instanceof EditorKit))
            return null;
        
        EditorKit editorKit = (EditorKit) getBrowserPane().getEditorKit();
        return editorKit.getComponentKit().getComponentEditors();
    }

    /**
     * Do anything necessary for the editor to be used as a component
     * in embedded mode
     */
    @Override
    public void initComponentEmbedded() {
        // init file actions
        fileMenu.setVisible(false);
        saveServerButton.setVisible(false);
        saveServerCommentButton.setVisible(false);
        exitButton.setVisible(false);
        separatorFile.setVisible(false);
        
        // init view menu
        editorMenuItem.setVisible(false);
        sourceMenuItem.setVisible(false);
        separatorStructureView.setVisible(false);
        
        // remove the kit as focus listener
        getMainPane().removeFocusListener(((EditorKit) getBrowserPane().getEditorKit()).getComponentKit());
    }
    
    /**
     * Do anything necessary for the editor to be used as a component
     * in embedded mode
     */
    @Override
    public void initComponentDialog() {
        initComponentEmbedded();
        
        // init view menu
        editorMenuItem.setVisible(true);
        sourceMenuItem.setVisible(true);
        separatorStructureView.setVisible(true);
    }
    
    protected void initializeComponents() {
        initComponents();
    }
    
    public void setMode(int mode) throws URISyntaxException {
        this.mode = mode;

        switch (mode) {
            case MODE_LOCAL_PAGE_EDITOR:
                setLocalPageEditor();
                break;

            case MODE_PAGE_EDITOR:
                setPageEditor();
                break;
        }
        
        browserPane.setEditorKit(createEditorKit());        
        EditorKit kit = (EditorKit) browserPane.getEditorKit();
        kit.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), saveMenuItem.getAction());

        EditorModel model = new EditorModel(new DocumentContext(browserPane));
        Element body = model.findNextElement(browserPane.getDocument().getDefaultRootElement(), HTML.Tag.BODY.toString());
        if (body != null)
            browserPane.setCaretPosition(body.getStartOffset());
        
    }
    
    /**
     * Factory to use modified editor kits in inheriting classes.
     * 
     * @return the EditorKit
     */
    protected EditorKit createEditorKit() {
        return new EditorKit(this);
    }

    /**
     * Edit an  HTML page and save it to a file. Used for
     * testing only.
     * 
     * @throws URISyntaxException
     */
    protected void setLocalPageEditor() throws URISyntaxException {
        treeHeadingMenuItem.doClick();

        chooser = new JFileChooser();
        chooser.setCurrentDirectory(new File(new URI(getBase())));

        fileMenu.addSeparator();
        fileMenu.add(newFileMenuItem);
        fileMenu.add(openFileMenuItem);
        fileMenu.add(saveFileMenuItem);
        fileMenu.add(saveFileAsMenuItem);

        toolBar.add(newFileButton, 0);
        toolBar.add(openFileButton, 1);
        toolBar.add(saveFileButton, 2);
        toolBar.add(saveFileAsButton, 3);
        
        getStructure().addNodePopups(ParagraphActions.getParagraphStructurePopups(this));
    }

    /**
     * The most ordinary mode: edit an HTML page.
     */
    protected void setPageEditor() {
        treeHeadingMenuItem.doClick();
        getStructure().addNodePopups(ParagraphActions.getParagraphStructurePopups(this));
    }

    public HashMap getProperties() {
        return properties;
    }

    public void addUserCaretListener(UserCaretListener listener) {
        caretListeners.add(listener);
    }

    public void clearCaretListeners() {
        caretListeners.clear();
    }

    public void fireUserCaretEvent() {
        Iterator<UserCaretListener> i = caretListeners.iterator();
        while (i.hasNext()) {
            i.next().userSetCaret();
        }
    }

    public void setContainer(Container container) {
        this.container = container;
    }

    public Result getResult() {
        return result;
    }

    public void open(URL url) throws IOException {
        getBrowserPane().setPage(url);
        setupPane();
    }

    public void close() {
        if (container != null)
            container.setVisible(false);
        else
            setVisible(false);
    }
    
    protected StructureTree createStructureTree(JEditorPane pane, JTree tree, HashMap editorProperties, Editor editor) {
        return new StructureTree(getBrowserPane(), getStructureTree(), getProperties(), this);
    }

    protected void setupPane() {
        NodePopup[] headingNodePopups = getHeading().getNodePopups();
        setHeading(new HeadingTree(getBrowserPane(), getHeadingTree(), this));

        NodePopup[] structureNodePopups = getStructure().getNodePopups();
        setStructure(createStructureTree(getBrowserPane(), getStructureTree(), getProperties(), this));

        getBrowserPane().getDocument().addUndoableEditListener(getUndoableEditListener());
        getHeading().update();
        if (headingNodePopups != null && headingNodePopups.length > 0)
            getHeading().setNodePopups(headingNodePopups);
        else
            getHeading().setNodePopups(ParagraphActions.getParagraphHeadingPopups(this));

        getStructure().update();
        getStructure().setNodePopups(structureNodePopups);

    }

    public boolean isManagingFocus() {
        return true;
    }

    public boolean isFocusable() {
        return false;
    }

    public static Editor getEditor(JEditorPane editorPane) {
        return editors.get(editorPane);
    }

    /** Creates new form Browser */
    public void startUI() {
        initActions();
        Locale locale = Locale.getDefault();
        initializeComponents();

        editors.put(browserPane, this);

        heading = new HeadingTree(browserPane, headingTree, this);
        structure = createStructureTree(browserPane, structureTree, properties, this);

        BasicSplitPaneUI ui = (BasicSplitPaneUI) browserSplitPane.getUI();
        ui.getDivider().setBorder(BorderFactory.createEmptyBorder());

        new FileActions.NewFileAction(this).actionPerformed(null);
        ((CardLayout) treePanel.getLayout()).show(treePanel, "headings");

        ((CardLayout) mainPanel.getLayout()).show(mainPanel, "browser");

        setFocusCycleRoot(true);
        browserPane.requestFocusInWindow();
    }
    protected Action saveTemplateAs;

    protected void initActions() {
        undoManager = new UndoActions.EditorActionUndoManager(this);
        undoAction = new UndoActions.UndoAction(this);
        redoAction = new UndoActions.RedoAction((this));
        undoableEditListener = new UndoActions.EditorUndoableEditListener(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        newFileMenuItem = new javax.swing.JMenuItem();
        saveFileMenuItem = new javax.swing.JMenuItem();
        saveFileAsMenuItem = new javax.swing.JMenuItem();
        openFileMenuItem = new javax.swing.JMenuItem();
        templateMenuBar = new javax.swing.JMenuBar();
        templateMenu = new javax.swing.JMenu();
        treeViewButtonGroup = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        newFileButton = new javax.swing.JButton();
        openFileButton = new javax.swing.JButton();
        saveFileButton = new javax.swing.JButton();
        saveFileAsButton = new javax.swing.JButton();
        addStyleSheetMenuItem = new javax.swing.JMenuItem();
        mainViewButtonGroup = new javax.swing.ButtonGroup();
        toolBar = new javax.swing.JToolBar();
        saveServerButton = new javax.swing.JButton();
        saveServerCommentButton = new javax.swing.JButton();
        exitButton = new javax.swing.JButton();
        separatorFile = new javax.swing.JToolBar.Separator();
        numberedListButton = new javax.swing.JButton();
        bulletListButton = new javax.swing.JButton();
        indentLeftButton = new javax.swing.JButton();
        indentRightButton = new javax.swing.JButton();
        separatorIndent = new javax.swing.JToolBar.Separator();
        heading1Button = new javax.swing.JButton();
        heading2Button = new javax.swing.JButton();
        codeButton = new javax.swing.JButton();
        separatorParagraph = new javax.swing.JToolBar.Separator();
        boldButton = new javax.swing.JButton();
        italicButton = new javax.swing.JButton();
        underlineButton = new javax.swing.JButton();
        codeSpanButton = new javax.swing.JButton();
        separatorCharacter = new javax.swing.JToolBar.Separator();
        treeHeadingButton = new javax.swing.JButton();
        treeStructureButton = new javax.swing.JButton();
        separatorStructure = new javax.swing.JToolBar.Separator();
        hyperlinkButton = new javax.swing.JButton();
        imageButton = new javax.swing.JButton();
        mainPanel = new javax.swing.JPanel();
        sourceScroll = new javax.swing.JScrollPane();
        sourcePane = new javax.swing.JTextPane();
        xslScroll = new javax.swing.JScrollPane();
        xslPane = new javax.swing.JTextPane();
        dataScroll = new javax.swing.JScrollPane();
        dataPane = new javax.swing.JTextPane();
        browserSplitPane = new javax.swing.JSplitPane();
        componentTreePanels = new javax.swing.JPanel();
        treePanel = new javax.swing.JPanel();
        headingScroll = new javax.swing.JScrollPane();
        headingTree = new javax.swing.JTree();
        structureScroll = new javax.swing.JScrollPane();
        structureTree = new javax.swing.JTree();
        templateSplitPane = new javax.swing.JSplitPane();
        schemaPanel = new javax.swing.JPanel();
        schemaScroll = new javax.swing.JScrollPane();
        schemaTree = new javax.swing.JTree();
        templateStructureScroll = new javax.swing.JScrollPane();
        browserScroll = new javax.swing.JScrollPane();
        browserPane = new javax.swing.JEditorPane();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        saveMenuItem = new javax.swing.JMenuItem();
        saveCommentMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        undoMenuItem = new javax.swing.JMenuItem();
        redoMenuItem = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        viewMenu = new javax.swing.JMenu();
        treeHeadingMenuItem = new javax.swing.JRadioButtonMenuItem();
        treeStructureMenuItem = new javax.swing.JRadioButtonMenuItem();
        separatorStructureView = new javax.swing.JSeparator();
        editorMenuItem = new javax.swing.JRadioButtonMenuItem();
        sourceMenuItem = new javax.swing.JRadioButtonMenuItem();
        insertMenu = new javax.swing.JMenu();
        insertBulletListMenuItem = new javax.swing.JMenuItem();
        insertNumberedListMenuItem = new javax.swing.JMenuItem();
        insertParagraphMenu = new javax.swing.JMenu();
        heading1MenuItem = new javax.swing.JMenuItem();
        heading2MenuItem = new javax.swing.JMenuItem();
        heading3MenuItem = new javax.swing.JMenuItem();
        heading4MenuItem = new javax.swing.JMenuItem();
        heading5MenuItem = new javax.swing.JMenuItem();
        heading6MenuItem = new javax.swing.JMenuItem();
        standardMenuItem = new javax.swing.JMenuItem();
        codeMenuItem = new javax.swing.JMenuItem();
        insertCharacterMenu = new javax.swing.JMenu();
        boldMenuItem = new javax.swing.JMenuItem();
        italicMenuItem = new javax.swing.JMenuItem();
        underlineMenuItem = new javax.swing.JMenuItem();
        codeSpanMenuItem = new javax.swing.JMenuItem();
        standardSpanMenuItem = new javax.swing.JMenuItem();
        stylesMenuItem = new javax.swing.JMenuItem();
        hyperlinkMenuItem = new javax.swing.JMenuItem();
        imageMenuItem = new javax.swing.JMenuItem();
        selectComponentMenuItem = new javax.swing.JMenuItem();
        tableMenu = new javax.swing.JMenu();
        insertTableMenuItem = new javax.swing.JMenuItem();
        insertRowMenu = new javax.swing.JMenu();
        insertRowBelow = new javax.swing.JMenuItem();
        insertRowAbove = new javax.swing.JMenuItem();
        insertColumnMenu = new javax.swing.JMenu();
        insertColumnRightMenuItem = new javax.swing.JMenuItem();
        insertColumnLeftMenuItem = new javax.swing.JMenuItem();
        deleteRowMenuItem = new javax.swing.JMenuItem();
        deleteColumnMenuItem = new javax.swing.JMenuItem();

        newFileMenuItem.setAction(new FileActions.NewFileAction(this));

        saveFileMenuItem.setAction(new FileActions.SaveFileAction(this));

        saveFileAsMenuItem.setAction(new FileActions.SaveFileAsAction(this));

        openFileMenuItem.setAction(new FileActions.OpenFileAction(this));

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("offset/nodes/client/editor/view/resources/EditorBundle"); // NOI18N
        templateMenu.setText(bundle.getString("Editor.Template")); // NOI18N
        templateMenuBar.add(templateMenu);

        newFileButton.setAction(new FileActions.NewFileAction( this ));
        newFileButton.setText(" ");
        newFileButton.setMargin(new java.awt.Insets(2, 2, 2, 2));

        openFileButton.setAction(new FileActions.OpenFileAction(this));
        openFileButton.setText(" ");
        openFileButton.setMargin(new java.awt.Insets(2, 2, 2, 2));

        saveFileButton.setAction(new FileActions.SaveFileAction( this ));
        saveFileButton.setText(" ");
        saveFileButton.setMargin(new java.awt.Insets(2, 2, 2, 2));

        saveFileAsButton.setAction(new FileActions.SaveFileAsAction(this));
        saveFileAsButton.setText(" ");
        saveFileAsButton.setMargin(new java.awt.Insets(2, 2, 2, 2));

        addStyleSheetMenuItem.setAction(new FileActions.AddStyleSheetAction(this));

        setName("nodesss"); // NOI18N
        getContentPane().setLayout(new java.awt.GridBagLayout());

        toolBar.setFloatable(false);
        toolBar.setRollover(true);
        toolBar.setPreferredSize(new java.awt.Dimension(1000, 27));

        saveServerButton.setAction(new FileActions.SaveServerAction(this));
        saveServerButton.setText(" ");
        saveServerButton.setFocusable(false);
        saveServerButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        saveServerButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        saveServerButton.setPreferredSize(new java.awt.Dimension(15, 25));
        toolBar.add(saveServerButton);

        saveServerCommentButton.setAction(new FileActions.SaveServerCommentAction(this));
        saveServerCommentButton.setText(" ");
        saveServerCommentButton.setFocusable(false);
        saveServerCommentButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        saveServerCommentButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        toolBar.add(saveServerCommentButton);

        exitButton.setAction(new FileActions.ExitAction( this ));
        exitButton.setText(" ");
        exitButton.setFocusable(false);
        exitButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        exitButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        toolBar.add(exitButton);
        toolBar.add(separatorFile);

        numberedListButton.setAction(new ListActions.ToggleListAction(HTML.Tag.OL, this));
        numberedListButton.setText(" ");
        numberedListButton.setToolTipText(bundle.getString("Numbered_list")); // NOI18N
        numberedListButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        toolBar.add(numberedListButton);

        bulletListButton.setAction(new ListActions.ToggleListAction(HTML.Tag.UL, this));
        bulletListButton.setText(" ");
        bulletListButton.setToolTipText(bundle.getString("Bullet_list")); // NOI18N
        bulletListButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        toolBar.add(bulletListButton);

        indentLeftButton.setAction(new EditorActions.BackTabAction(this));
        indentLeftButton.setText(" ");
        indentLeftButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        toolBar.add(indentLeftButton);

        indentRightButton.setAction(new EditorActions.TabAction(this));
        indentRightButton.setText(" ");
        indentRightButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
        toolBar.add(indentRightButton);
        toolBar.add(separatorIndent);

        heading1Button.setAction(new ParagraphActions.InsertHeading1Action(this));
        heading1Button.setText(" ");
        heading1Button.setFocusable(false);
        heading1Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(heading1Button);

        heading2Button.setAction(new ParagraphActions.InsertHeading2Action(this));
        heading2Button.setText(" ");
        heading2Button.setFocusable(false);
        heading2Button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(heading2Button);

        codeButton.setAction(new ParagraphActions.InsertCodeAction(this));
        codeButton.setText(" ");
        codeButton.setFocusable(false);
        codeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(codeButton);
        toolBar.add(separatorParagraph);

        boldButton.setAction(new CharacterActions.BoldAction(this) );
        boldButton.setText(" ");
        boldButton.setFocusable(false);
        boldButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(boldButton);

        italicButton.setAction(new CharacterActions.ItalicAction(this));
        italicButton.setText(" ");
        italicButton.setFocusable(false);
        italicButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(italicButton);

        underlineButton.setAction(new CharacterActions.UnderlineAction(this));
        underlineButton.setText(" ");
        underlineButton.setFocusable(false);
        underlineButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(underlineButton);

        codeSpanButton.setAction(new CharacterActions.CodeAction(this));
        codeSpanButton.setText(" ");
        codeSpanButton.setFocusable(false);
        codeSpanButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(codeSpanButton);
        toolBar.add(separatorCharacter);

        treeHeadingButton.setAction(new ViewActions.HeadingViewAction(this));
        treeHeadingButton.setText(" ");
        treeHeadingButton.setFocusable(false);
        treeHeadingButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(treeHeadingButton);

        treeStructureButton.setAction(new ViewActions.StructureViewAction(this));
        treeStructureButton.setText(" ");
        treeStructureButton.setFocusable(false);
        treeStructureButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(treeStructureButton);
        toolBar.add(separatorStructure);

        hyperlinkButton.setAction(new HyperlinkActions.InsertHyperlinkAction(this));
        hyperlinkButton.setText(" ");
        hyperlinkButton.setFocusable(false);
        hyperlinkButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolBar.add(hyperlinkButton);

        imageButton.setAction(new ImageActions.InsertImageAction(this));
        imageButton.setText(" ");
        imageButton.setFocusable(false);
        imageButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        imageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                imageButtonActionPerformed(evt);
            }
        });
        toolBar.add(imageButton);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        getContentPane().add(toolBar, gridBagConstraints);

        mainPanel.setNextFocusableComponent(browserPane);
        mainPanel.setLayout(new java.awt.CardLayout());

        sourceScroll.setBackground(new java.awt.Color(255, 255, 204));

        sourcePane.setBackground(new java.awt.Color(255, 255, 204));
        sourceScroll.setViewportView(sourcePane);

        mainPanel.add(sourceScroll, "source");

        xslPane.setBackground(new java.awt.Color(255, 223, 226));
        xslScroll.setViewportView(xslPane);

        mainPanel.add(xslScroll, "xsl");

        dataPane.setBackground(new java.awt.Color(255, 223, 226));
        dataScroll.setViewportView(dataPane);

        mainPanel.add(dataScroll, "data");

        browserSplitPane.setBorder(null);
        browserSplitPane.setDividerLocation(0);
        browserSplitPane.setDividerSize(4);
        browserSplitPane.setContinuousLayout(true);
        browserSplitPane.setLastDividerLocation(220);
        browserSplitPane.setNextFocusableComponent(browserPane);
        browserSplitPane.setOneTouchExpandable(true);

        componentTreePanels.setPreferredSize(new java.awt.Dimension(86, 600));
        componentTreePanels.setLayout(new java.awt.CardLayout());

        treePanel.setLayout(new java.awt.CardLayout());

        headingTree.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        headingScroll.setViewportView(headingTree);

        treePanel.add(headingScroll, "headings");

        structureTree.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        structureScroll.setViewportView(structureTree);

        treePanel.add(structureScroll, "structure");

        templateSplitPane.setBorder(null);
        templateSplitPane.setDividerLocation(200);
        templateSplitPane.setDividerSize(3);
        templateSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        schemaPanel.setLayout(new java.awt.BorderLayout());

        schemaTree.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        schemaScroll.setViewportView(schemaTree);

        schemaPanel.add(schemaScroll, java.awt.BorderLayout.CENTER);

        templateSplitPane.setLeftComponent(schemaPanel);
        templateSplitPane.setRightComponent(templateStructureScroll);

        treePanel.add(templateSplitPane, "template");

        componentTreePanels.add(treePanel, "main");

        browserSplitPane.setLeftComponent(componentTreePanels);

        browserScroll.setNextFocusableComponent(browserPane);

        browserPane.setContentType("text/html"); // NOI18N
        browserPane.setPreferredSize(new java.awt.Dimension(600, 20));
        browserPane.setSelectionColor(new java.awt.Color(153, 153, 255));
        browserScroll.setViewportView(browserPane);

        browserSplitPane.setRightComponent(browserScroll);

        mainPanel.add(browserSplitPane, "browser");

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        getContentPane().add(mainPanel, gridBagConstraints);

        fileMenu.setText(bundle.getString("File")); // NOI18N

        saveMenuItem.setAction(new FileActions.SaveServerAction(this));
        saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(saveMenuItem);

        saveCommentMenuItem.setAction(new FileActions.SaveServerCommentAction(this));
        fileMenu.add(saveCommentMenuItem);

        exitMenuItem.setAction(new FileActions.ExitAction(this));
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setText(bundle.getString("Edit")); // NOI18N

        undoMenuItem.setAction(this.undoAction);
        editMenu.add(undoMenuItem);

        redoMenuItem.setAction(this.redoAction);
        editMenu.add(redoMenuItem);
        editMenu.add(jSeparator1);

        cutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        cutMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/offset/nodes/client/editor/view/resources/sc_cut.png"))); // NOI18N
        cutMenuItem.setText(bundle.getString("Cut")); // NOI18N
        editMenu.add(cutMenuItem);

        copyMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/offset/nodes/client/editor/view/resources/sc_copy.png"))); // NOI18N
        copyMenuItem.setText(bundle.getString("Copy")); // NOI18N
        editMenu.add(copyMenuItem);

        pasteMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/offset/nodes/client/editor/view/resources/sc_paste.png"))); // NOI18N
        pasteMenuItem.setText(bundle.getString("Paste")); // NOI18N
        editMenu.add(pasteMenuItem);

        menuBar.add(editMenu);

        viewMenu.setText(bundle.getString("View")); // NOI18N

        treeHeadingMenuItem.setAction(treeHeadingButton.getAction());
        treeViewButtonGroup.add(treeHeadingMenuItem);
        treeHeadingMenuItem.setSelected(true);
        treeHeadingMenuItem.setText(bundle.getString("Heading")); // NOI18N
        treeHeadingMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                treeHeadingMenuItemActionPerformed(evt);
            }
        });
        viewMenu.add(treeHeadingMenuItem);

        treeStructureMenuItem.setAction(treeStructureButton.getAction());
        treeViewButtonGroup.add(treeStructureMenuItem);
        treeStructureMenuItem.setText(bundle.getString("Structure")); // NOI18N
        viewMenu.add(treeStructureMenuItem);
        viewMenu.add(separatorStructureView);

        editorMenuItem.setAction(new ViewActions.EditorViewAction(this));
        mainViewButtonGroup.add(editorMenuItem);
        editorMenuItem.setSelected(true);
        editorMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editorMenuItemActionPerformed(evt);
            }
        });
        viewMenu.add(editorMenuItem);

        sourceMenuItem.setAction(new ViewActions.SourceViewAction(this));
        mainViewButtonGroup.add(sourceMenuItem);
        viewMenu.add(sourceMenuItem);

        menuBar.add(viewMenu);

        insertMenu.setText(bundle.getString("Format")); // NOI18N

        insertBulletListMenuItem.setAction(bulletListButton.getAction());
        insertMenu.add(insertBulletListMenuItem);

        insertNumberedListMenuItem.setAction(numberedListButton.getAction());
        insertMenu.add(insertNumberedListMenuItem);

        insertParagraphMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/offset/nodes/client/editor/view/resources/sc_paragraph.png"))); // NOI18N
        insertParagraphMenu.setText(bundle.getString("insert.paragraph")); // NOI18N

        heading1MenuItem.setAction(heading1Button.getAction());
        heading1MenuItem.setText(bundle.getString("Heading_1")); // NOI18N
        insertParagraphMenu.add(heading1MenuItem);

        heading2MenuItem.setAction(heading2Button.getAction());
        heading2MenuItem.setText(bundle.getString("Heading_2")); // NOI18N
        insertParagraphMenu.add(heading2MenuItem);

        heading3MenuItem.setAction(new ParagraphActions.InsertHeading3Action(this));
        insertParagraphMenu.add(heading3MenuItem);

        heading4MenuItem.setAction(new ParagraphActions.InsertHeading4Action(this));
        insertParagraphMenu.add(heading4MenuItem);

        heading5MenuItem.setAction(new ParagraphActions.InsertHeading5Action(this));
        insertParagraphMenu.add(heading5MenuItem);

        heading6MenuItem.setAction(new ParagraphActions.InsertHeading6Action(this));
        insertParagraphMenu.add(heading6MenuItem);

        standardMenuItem.setAction(new ParagraphActions.InsertStandardAction(this));
        insertParagraphMenu.add(standardMenuItem);

        codeMenuItem.setAction(codeButton.getAction());
        codeMenuItem.setText(bundle.getString("Code")); // NOI18N
        insertParagraphMenu.add(codeMenuItem);

        insertMenu.add(insertParagraphMenu);

        insertCharacterMenu.setText(bundle.getString("insert.character")); // NOI18N

        boldMenuItem.setAction(boldButton.getAction());
        boldMenuItem.setText(bundle.getString("insert.character.bold")); // NOI18N
        boldMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boldMenuItemActionPerformed(evt);
            }
        });
        insertCharacterMenu.add(boldMenuItem);

        italicMenuItem.setAction(italicButton.getAction());
        italicMenuItem.setText(bundle.getString("insert.character.italic")); // NOI18N
        insertCharacterMenu.add(italicMenuItem);

        underlineMenuItem.setAction(underlineButton.getAction());
        underlineMenuItem.setText(bundle.getString("insert.character.underline")); // NOI18N
        insertCharacterMenu.add(underlineMenuItem);

        codeSpanMenuItem.setAction(codeSpanButton.getAction());
        codeSpanMenuItem.setText(bundle.getString("insert.character.code")); // NOI18N
        insertCharacterMenu.add(codeSpanMenuItem);

        standardSpanMenuItem.setAction(new CharacterActions.StandardAction(this));
        standardSpanMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                standardSpanMenuItemActionPerformed(evt);
            }
        });
        insertCharacterMenu.add(standardSpanMenuItem);

        insertMenu.add(insertCharacterMenu);

        stylesMenuItem.setAction(new ParagraphActions.AddStyleAction(this));
        stylesMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stylesMenuItemActionPerformed(evt);
            }
        });
        insertMenu.add(stylesMenuItem);

        hyperlinkMenuItem.setAction(hyperlinkButton.getAction());
        hyperlinkMenuItem.setText(bundle.getString("NewHyperlink")); // NOI18N
        insertMenu.add(hyperlinkMenuItem);

        imageMenuItem.setAction(imageButton.getAction());
        imageMenuItem.setText(bundle.getString("EditImage")); // NOI18N
        insertMenu.add(imageMenuItem);

        selectComponentMenuItem.setAction(new ComponentActions.SelectComponentAction(this));
        selectComponentMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/offset/nodes/client/editor/view/resources/sc_component.png"))); // NOI18N
        selectComponentMenuItem.setText(bundle.getString("component.select")); // NOI18N
        insertMenu.add(selectComponentMenuItem);

        menuBar.add(insertMenu);

        tableMenu.setText(bundle.getString("Table")); // NOI18N

        insertTableMenuItem.setAction(new TableActions.InsertTableAction(this));
        tableMenu.add(insertTableMenuItem);

        insertRowMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/offset/nodes/client/editor/view/resources/sc_insertrows.png"))); // NOI18N
        insertRowMenu.setText(bundle.getString("Insert_Row")); // NOI18N

        insertRowBelow.setAction(new TableActions.InsertRowBelowAction(this));
        insertRowMenu.add(insertRowBelow);

        insertRowAbove.setAction(new TableActions.InsertRowAboveAction(this));
        insertRowMenu.add(insertRowAbove);

        tableMenu.add(insertRowMenu);

        insertColumnMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/offset/nodes/client/editor/view/resources/sc_insertcolumns.png"))); // NOI18N
        insertColumnMenu.setText(bundle.getString("Insert_Column")); // NOI18N

        insertColumnRightMenuItem.setAction(new TableActions.InsertColumnRightAction(this));
        insertColumnMenu.add(insertColumnRightMenuItem);

        insertColumnLeftMenuItem.setAction(new TableActions.InsertColumnLeftAction(this));
        insertColumnMenu.add(insertColumnLeftMenuItem);

        tableMenu.add(insertColumnMenu);

        deleteRowMenuItem.setAction(new TableActions.DeleteRowAction(this));
        deleteRowMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteRowMenuItemActionPerformed(evt);
            }
        });
        tableMenu.add(deleteRowMenuItem);

        deleteColumnMenuItem.setAction(new TableActions.DeleteColumnAction(this));
        tableMenu.add(deleteColumnMenuItem);

        menuBar.add(tableMenu);

        setJMenuBar(menuBar);
    }// </editor-fold>//GEN-END:initComponents
    private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuItemActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_saveMenuItemActionPerformed

    private void treeHeadingMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_treeHeadingMenuItemActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_treeHeadingMenuItemActionPerformed

    private void boldMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boldMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_boldMenuItemActionPerformed

    private void standardSpanMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_standardSpanMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_standardSpanMenuItemActionPerformed

    private void deleteRowMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteRowMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_deleteRowMenuItemActionPerformed

    private void stylesMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stylesMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_stylesMenuItemActionPerformed

    private void editorMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editorMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_editorMenuItemActionPerformed

    private void imageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imageButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_imageButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem addStyleSheetMenuItem;
    private javax.swing.JButton boldButton;
    private javax.swing.JMenuItem boldMenuItem;
    private javax.swing.JEditorPane browserPane;
    private javax.swing.JScrollPane browserScroll;
    private javax.swing.JSplitPane browserSplitPane;
    private javax.swing.JButton bulletListButton;
    private javax.swing.JButton codeButton;
    private javax.swing.JMenuItem codeMenuItem;
    private javax.swing.JButton codeSpanButton;
    private javax.swing.JMenuItem codeSpanMenuItem;
    private javax.swing.JPanel componentTreePanels;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JTextPane dataPane;
    private javax.swing.JScrollPane dataScroll;
    private javax.swing.JMenuItem deleteColumnMenuItem;
    private javax.swing.JMenuItem deleteRowMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JRadioButtonMenuItem editorMenuItem;
    private javax.swing.JButton exitButton;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JButton heading1Button;
    private javax.swing.JMenuItem heading1MenuItem;
    private javax.swing.JButton heading2Button;
    private javax.swing.JMenuItem heading2MenuItem;
    private javax.swing.JMenuItem heading3MenuItem;
    private javax.swing.JMenuItem heading4MenuItem;
    private javax.swing.JMenuItem heading5MenuItem;
    private javax.swing.JMenuItem heading6MenuItem;
    private javax.swing.JScrollPane headingScroll;
    private javax.swing.JTree headingTree;
    private javax.swing.JButton hyperlinkButton;
    private javax.swing.JMenuItem hyperlinkMenuItem;
    private javax.swing.JButton imageButton;
    private javax.swing.JMenuItem imageMenuItem;
    private javax.swing.JButton indentLeftButton;
    private javax.swing.JButton indentRightButton;
    private javax.swing.JMenuItem insertBulletListMenuItem;
    private javax.swing.JMenu insertCharacterMenu;
    private javax.swing.JMenuItem insertColumnLeftMenuItem;
    private javax.swing.JMenu insertColumnMenu;
    private javax.swing.JMenuItem insertColumnRightMenuItem;
    private javax.swing.JMenu insertMenu;
    private javax.swing.JMenuItem insertNumberedListMenuItem;
    private javax.swing.JMenu insertParagraphMenu;
    private javax.swing.JMenuItem insertRowAbove;
    private javax.swing.JMenuItem insertRowBelow;
    private javax.swing.JMenu insertRowMenu;
    private javax.swing.JMenuItem insertTableMenuItem;
    private javax.swing.JButton italicButton;
    private javax.swing.JMenuItem italicMenuItem;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.ButtonGroup mainViewButtonGroup;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JButton newFileButton;
    private javax.swing.JMenuItem newFileMenuItem;
    private javax.swing.JButton numberedListButton;
    private javax.swing.JButton openFileButton;
    private javax.swing.JMenuItem openFileMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem redoMenuItem;
    private javax.swing.JMenuItem saveCommentMenuItem;
    private javax.swing.JButton saveFileAsButton;
    private javax.swing.JMenuItem saveFileAsMenuItem;
    private javax.swing.JButton saveFileButton;
    private javax.swing.JMenuItem saveFileMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    private javax.swing.JButton saveServerButton;
    private javax.swing.JButton saveServerCommentButton;
    private javax.swing.JPanel schemaPanel;
    private javax.swing.JScrollPane schemaScroll;
    private javax.swing.JTree schemaTree;
    private javax.swing.JMenuItem selectComponentMenuItem;
    private javax.swing.JToolBar.Separator separatorCharacter;
    private javax.swing.JToolBar.Separator separatorFile;
    private javax.swing.JToolBar.Separator separatorIndent;
    private javax.swing.JToolBar.Separator separatorParagraph;
    private javax.swing.JToolBar.Separator separatorStructure;
    private javax.swing.JSeparator separatorStructureView;
    private javax.swing.JRadioButtonMenuItem sourceMenuItem;
    private javax.swing.JTextPane sourcePane;
    private javax.swing.JScrollPane sourceScroll;
    private javax.swing.JMenuItem standardMenuItem;
    private javax.swing.JMenuItem standardSpanMenuItem;
    private javax.swing.JScrollPane structureScroll;
    private javax.swing.JTree structureTree;
    private javax.swing.JMenuItem stylesMenuItem;
    private javax.swing.JMenu tableMenu;
    private javax.swing.JMenu templateMenu;
    private javax.swing.JMenuBar templateMenuBar;
    private javax.swing.JSplitPane templateSplitPane;
    private javax.swing.JScrollPane templateStructureScroll;
    private javax.swing.JToolBar toolBar;
    private javax.swing.JButton treeHeadingButton;
    private javax.swing.JRadioButtonMenuItem treeHeadingMenuItem;
    private javax.swing.JPanel treePanel;
    private javax.swing.JButton treeStructureButton;
    private javax.swing.JRadioButtonMenuItem treeStructureMenuItem;
    private javax.swing.ButtonGroup treeViewButtonGroup;
    private javax.swing.JButton underlineButton;
    private javax.swing.JMenuItem underlineMenuItem;
    private javax.swing.JMenuItem undoMenuItem;
    private javax.swing.JMenu viewMenu;
    private javax.swing.JTextPane xslPane;
    private javax.swing.JScrollPane xslScroll;
    // End of variables declaration//GEN-END:variables

    public javax.swing.JEditorPane getBrowserPane() {
        return browserPane;
    }

    public javax.swing.JScrollPane getBrowserScroll() {
        return browserScroll;
    }

    public javax.swing.JSplitPane getBrowserSplitPane() {
        return browserSplitPane;
    }

    public javax.swing.JButton getBulletListButton() {
        return bulletListButton;
    }

    public JFileChooser getChooser() {
        return chooser;
    }

    public javax.swing.JMenuItem getCodeMenuItem() {
        return codeMenuItem;
    }

    public javax.swing.JMenuItem getCopyMenuItem() {
        return copyMenuItem;
    }

    public javax.swing.JMenuItem getCutMenuItem() {
        return cutMenuItem;
    }

    public boolean isDebug() {
        return debug;
    }

    public javax.swing.JMenuItem getDeleteColumnMenuItem() {
        return deleteColumnMenuItem;
    }

    public javax.swing.JMenuItem getDeleteRowMenuItem() {
        return deleteRowMenuItem;
    }

    public javax.swing.JMenu getEditMenu() {
        return editMenu;
    }

    public javax.swing.JMenu getFileMenu() {
        return fileMenu;
    }

    public HeadingTree getHeading() {
        return heading;
    }

    public javax.swing.JMenuItem getHeading1MenuItem() {
        return heading1MenuItem;
    }

    public javax.swing.JMenuItem getHeading2MenuItem() {
        return heading2MenuItem;
    }

    public javax.swing.JMenuItem getHeading3MenuItem() {
        return heading3MenuItem;
    }

    public javax.swing.JMenuItem getHeading4MenuItem() {
        return heading4MenuItem;
    }

    public javax.swing.JMenuItem getHeading5MenuItem() {
        return heading5MenuItem;
    }

    public javax.swing.JMenuItem getHeading6MenuItem() {
        return heading6MenuItem;
    }

    public javax.swing.JScrollPane getHeadingScroll() {
        return headingScroll;
    }

    public javax.swing.JTree getHeadingTree() {
        return headingTree;
    }

    public javax.swing.JButton getIndentLeftButton() {
        return indentLeftButton;
    }

    public javax.swing.JButton getIndentRightButton() {
        return indentRightButton;
    }

    public javax.swing.JMenuItem getInsertBulletListMenuItem() {
        return insertBulletListMenuItem;
    }

    public javax.swing.JMenuItem getInsertColumnLeftMenuItem() {
        return insertColumnLeftMenuItem;
    }

    public javax.swing.JMenu getInsertColumnMenu() {
        return insertColumnMenu;
    }

    public javax.swing.JMenuItem getInsertColumnRightMenuItem() {
        return insertColumnRightMenuItem;
    }

    public javax.swing.JMenu getInsertMenu() {
        return insertMenu;
    }

    public javax.swing.JMenuItem getInsertNumberedListMenuItem() {
        return insertNumberedListMenuItem;
    }

    public javax.swing.JMenu getInsertParagraphMenu() {
        return insertParagraphMenu;
    }

    public javax.swing.JMenuItem getInsertRowAbove() {
        return insertRowAbove;
    }

    public javax.swing.JMenuItem getInsertRowBelow() {
        return insertRowBelow;
    }

    public javax.swing.JMenu getInsertRowMenu() {
        return insertRowMenu;
    }

    public javax.swing.JMenuItem getInsertTableMenuItem() {
        return insertTableMenuItem;
    }

    public javax.swing.JPanel getMainPanel() {
        return mainPanel;
    }

    public javax.swing.JMenuBar getMenubar() {
        return menuBar;
    }

    public javax.swing.JButton getNewFileButton() {
        return newFileButton;
    }

    public javax.swing.JMenuItem getNewFileMenuItem() {
        return newFileMenuItem;
    }

    public javax.swing.JButton getNumberedListButton() {
        return numberedListButton;
    }

    public javax.swing.JButton getOpenFileButton() {
        return openFileButton;
    }

    public javax.swing.JMenuItem getPasteMenuItem() {
        return pasteMenuItem;
    }

    public javax.swing.JMenuItem getRedoMenuItem() {
        return redoMenuItem;
    }

    public javax.swing.JButton getSaveFileAsButton() {
        return saveFileAsButton;
    }

    public javax.swing.JMenuItem getSaveFileAsMenuItem() {
        return saveFileAsMenuItem;
    }

    public javax.swing.JButton getSaveFileButton() {
        return saveFileButton;
    }

    public javax.swing.JMenuItem getSaveFileMenuItem() {
        return saveFileMenuItem;
    }

    public javax.swing.JPanel getSchemaPanel() {
        return schemaPanel;
    }

    public javax.swing.JScrollPane getSchemaScroll() {
        return schemaScroll;
    }

    public javax.swing.JTree getSchemaTree() {
        return schemaTree;
    }

    public javax.swing.JTextPane getSourcePane() {
        return sourcePane;
    }

    public javax.swing.JScrollPane getSourceScroll() {
        return sourceScroll;
    }

    public JTextPane getXslPane() {
        return xslPane;
    }

    public JScrollPane getXslScroll() {
        return xslScroll;
    }

    public JTextPane getDataPane() {
        return dataPane;
    }

    public JScrollPane getDataScroll() {
        return dataScroll;
    }

    public javax.swing.JMenuItem getStandardMenuItem() {
        return standardMenuItem;
    }

    public StructureTree getStructure() {
        return structure;
    }

    public javax.swing.JScrollPane getStructureScroll() {
        return structureScroll;
    }

    public javax.swing.JTree getStructureTree() {
        return structureTree;
    }

    public javax.swing.JMenu getTableMenu() {
        return tableMenu;
    }

    public javax.swing.JMenu getTemplateMenu() {
        return templateMenu;
    }

    public javax.swing.JMenuBar getTemplateMenuBar() {
        return templateMenuBar;
    }

    public javax.swing.JSplitPane getTemplateSplitPane() {
        return templateSplitPane;
    }

    public javax.swing.JScrollPane getTemplateStructureScroll() {
        return templateStructureScroll;
    }

    public javax.swing.JRadioButtonMenuItem getSourceMenuItem() {
        return sourceMenuItem;
    }

    public javax.swing.JRadioButtonMenuItem getEditorMenuItem() {
        return editorMenuItem;
    }

    public javax.swing.JToolBar getToolBar() {
        return toolBar;
    }

    public javax.swing.JRadioButtonMenuItem getTreeHeadingMenuItem() {
        return treeHeadingMenuItem;
    }

    public javax.swing.JPanel getTreePanel() {
        return treePanel;
    }

    public javax.swing.JRadioButtonMenuItem getTreeStructureMenuItem() {
        return treeStructureMenuItem;
    }

    public javax.swing.ButtonGroup getTreeViewButtonGroup() {
        return treeViewButtonGroup;
    }

    public javax.swing.JMenuItem getUndoMenuItem() {
        return undoMenuItem;
    }

    public javax.swing.JMenu getViewMenu() {
        return viewMenu;
    }


    public void setBrowserPane(javax.swing.JEditorPane browserPane) {
        this.browserPane = browserPane;
    }

    public void setBrowserScroll(javax.swing.JScrollPane browserScroll) {
        this.browserScroll = browserScroll;
    }

    public void setBrowserSplitPane(javax.swing.JSplitPane browserSplitPane) {
        this.browserSplitPane = browserSplitPane;
    }

    public void setBulletListButton(javax.swing.JButton bulletListButton) {
        this.bulletListButton = bulletListButton;
    }

    public void setChooser(JFileChooser chooser) {
        this.chooser = chooser;
    }

    public void setCodeMenuItem(javax.swing.JMenuItem codeMenuItem) {
        this.codeMenuItem = codeMenuItem;
    }

    public void setCopyMenuItem(javax.swing.JMenuItem copyMenuItem) {
        this.copyMenuItem = copyMenuItem;
    }

    public void setCutMenuItem(javax.swing.JMenuItem cutMenuItem) {
        this.cutMenuItem = cutMenuItem;
    }

    public void setDebug(boolean debug) {
        this.debug = debug;
    }

    public void setDeleteColumnMenuItem(javax.swing.JMenuItem deleteColumnMenuItem) {
        this.deleteColumnMenuItem = deleteColumnMenuItem;
    }

    public void setDeleteRowMenuItem(javax.swing.JMenuItem deleteRowMenuItem) {
        this.deleteRowMenuItem = deleteRowMenuItem;
    }

    public void setEditMenu(javax.swing.JMenu editMenu) {
        this.editMenu = editMenu;
    }

    public void setFileMenu(javax.swing.JMenu fileMenu) {
        this.fileMenu = fileMenu;
    }

    public void setHeading(HeadingTree heading) {
        this.heading = heading;
    }

    public void setHeading1MenuItem(javax.swing.JMenuItem heading1MenuItem) {
        this.heading1MenuItem = heading1MenuItem;
    }

    public void setHeading2MenuItem(javax.swing.JMenuItem heading2MenuItem) {
        this.heading2MenuItem = heading2MenuItem;
    }

    public void setHeading3MenuItem(javax.swing.JMenuItem heading3MenuItem) {
        this.heading3MenuItem = heading3MenuItem;
    }

    public void setHeading4MenuItem(javax.swing.JMenuItem heading4MenuItem) {
        this.heading4MenuItem = heading4MenuItem;
    }

    public void setHeading5MenuItem(javax.swing.JMenuItem heading5MenuItem) {
        this.heading5MenuItem = heading5MenuItem;
    }

    public void setHeading6MenuItem(javax.swing.JMenuItem heading6MenuItem) {
        this.heading6MenuItem = heading6MenuItem;
    }

    public void setHeadingScroll(javax.swing.JScrollPane headingScroll) {
        this.headingScroll = headingScroll;
    }

    public void setHeadingTree(javax.swing.JTree headingTree) {
        this.headingTree = headingTree;
    }

    public void setIndentLeftButton(javax.swing.JButton indentLeftButton) {
        this.indentLeftButton = indentLeftButton;
    }

    public void setIndentRightButton(javax.swing.JButton indentRightButton) {
        this.indentRightButton = indentRightButton;
    }

    public void setInsertBulletListMenuItem(
            javax.swing.JMenuItem insertBulletListMenuItem) {
        this.insertBulletListMenuItem = insertBulletListMenuItem;
    }

    public void setInsertColumnLeftMenuItem(
            javax.swing.JMenuItem insertColumnLeftMenuItem) {
        this.insertColumnLeftMenuItem = insertColumnLeftMenuItem;
    }

    public void setInsertColumnMenu(javax.swing.JMenu insertColumnMenu) {
        this.insertColumnMenu = insertColumnMenu;
    }

    public void setInsertColumnRightMenuItem(
            javax.swing.JMenuItem insertColumnRightMenuItem) {
        this.insertColumnRightMenuItem = insertColumnRightMenuItem;
    }

    public void setInsertMenu(javax.swing.JMenu insertMenu) {
        this.insertMenu = insertMenu;
    }

    public void setInsertNumberedListMenuItem(
            javax.swing.JMenuItem insertNumberedListMenuItem) {
        this.insertNumberedListMenuItem = insertNumberedListMenuItem;
    }

    public void setInsertParagraphMenu(javax.swing.JMenu insertParagraphMenu) {
        this.insertParagraphMenu = insertParagraphMenu;
    }

    public void setInsertRowAbove(javax.swing.JMenuItem insertRowAbove) {
        this.insertRowAbove = insertRowAbove;
    }

    public void setInsertRowBelow(javax.swing.JMenuItem insertRowBelow) {
        this.insertRowBelow = insertRowBelow;
    }

    public void setInsertRowMenu(javax.swing.JMenu insertRowMenu) {
        this.insertRowMenu = insertRowMenu;
    }

    public void setInsertTableMenuItem(javax.swing.JMenuItem insertTableMenuItem) {
        this.insertTableMenuItem = insertTableMenuItem;
    }

    public void setMainPanel(javax.swing.JPanel mainPanel) {
        this.mainPanel = mainPanel;
    }

    public void setMenuBar(javax.swing.JMenuBar menuBar) {
        this.menuBar = menuBar;
    }

    public void setNewFileButton(javax.swing.JButton newFileButton) {
        this.newFileButton = newFileButton;
    }

    public void setNewFileMenuItem(javax.swing.JMenuItem newFileMenuItem) {
        this.newFileMenuItem = newFileMenuItem;
    }

    public void setNumberedListButton(javax.swing.JButton numberedListButton) {
        this.numberedListButton = numberedListButton;
    }

    public void setOpenFileButton(javax.swing.JButton openFileButton) {
        this.openFileButton = openFileButton;
    }

    public void setPasteMenuItem(javax.swing.JMenuItem pasteMenuItem) {
        this.pasteMenuItem = pasteMenuItem;
    }

    public void setRedoMenuItem(javax.swing.JMenuItem redoMenuItem) {
        this.redoMenuItem = redoMenuItem;
    }

    public void setSaveFileAsButton(javax.swing.JButton saveFileAsButton) {
        this.saveFileAsButton = saveFileAsButton;
    }

    public void setSaveFileAsMenuItem(javax.swing.JMenuItem saveFileAsMenuItem) {
        this.saveFileAsMenuItem = saveFileAsMenuItem;
    }

    public void setSaveFileButton(javax.swing.JButton saveFileButton) {
        this.saveFileButton = saveFileButton;
    }

    public void setSaveFileMenuItem(javax.swing.JMenuItem saveFileMenuItem) {
        this.saveFileMenuItem = saveFileMenuItem;
    }

    public void setSchemaPanel(javax.swing.JPanel schemaPanel) {
        this.schemaPanel = schemaPanel;
    }

    public void setSchemaScroll(javax.swing.JScrollPane schemaScroll) {
        this.schemaScroll = schemaScroll;
    }

    public void setSchemaTree(javax.swing.JTree schemaTree) {
        this.schemaTree = schemaTree;
    }

    public void setSourcePane(javax.swing.JTextPane sourcePane) {
        this.sourcePane = sourcePane;
    }

    public void setSourceScroll(javax.swing.JScrollPane sourceScroll) {
        this.sourceScroll = sourceScroll;
    }

    public void setStandardMenuItem(javax.swing.JMenuItem standardMenuItem) {
        this.standardMenuItem = standardMenuItem;
    }

    public void setStructure(StructureTree structure) {
        this.structure = structure;
    }

    public void setStructureScroll(javax.swing.JScrollPane structureScroll) {
        this.structureScroll = structureScroll;
    }

    public void setStructureTree(javax.swing.JTree structureTree) {
        this.structureTree = structureTree;
    }

    public void setTableMenu(javax.swing.JMenu tableMenu) {
        this.tableMenu = tableMenu;
    }

    public void setTemplateMenu(javax.swing.JMenu templateMenu) {
        this.templateMenu = templateMenu;
    }

    public void setTemplateMenuBar(javax.swing.JMenuBar templateMenuBar) {
        this.templateMenuBar = templateMenuBar;
    }

    public void setTemplateSplitPane(javax.swing.JSplitPane templateSplitPane) {
        this.templateSplitPane = templateSplitPane;
    }

    public void setTemplateStructureScroll(
            javax.swing.JScrollPane templateStructureScroll) {
        this.templateStructureScroll = templateStructureScroll;
    }

    public void setToolBar(javax.swing.JToolBar toolBar) {
        this.toolBar = toolBar;
    }

    public void setTreeHeadingMenuItem(
            javax.swing.JRadioButtonMenuItem treeHeadingMenuItem) {
        this.treeHeadingMenuItem = treeHeadingMenuItem;
    }

    public void setTreePanel(javax.swing.JPanel treePanel) {
        this.treePanel = treePanel;
    }

    public void setTreeStructureMenuItem(
            javax.swing.JRadioButtonMenuItem treeStructureMenuItem) {
        this.treeStructureMenuItem = treeStructureMenuItem;
    }

    public void setTreeViewButtonGroup(javax.swing.ButtonGroup treeViewButtonGroup) {
        this.treeViewButtonGroup = treeViewButtonGroup;
    }

    public void setUndoMenuItem(javax.swing.JMenuItem undoMenuItem) {
        this.undoMenuItem = undoMenuItem;
    }

    public void setViewMenu(javax.swing.JMenu viewMenu) {
        this.viewMenu = viewMenu;
    }

    public Action getSaveTemplateAs() {
        return saveTemplateAs;
    }

    public void setSaveTemplateAs(Action saveTemplateAs) {
        this.saveTemplateAs = saveTemplateAs;
    }

    public String getBase() {
        return base;
    }

    public void setBase(String base) {
        this.base = base;
    }

    public int getMode() {
        return mode;
    }

    public UndoActions.EditorActionUndoManager getUndoManager() {
        return undoManager;
    }

    public UndoActions.EditorUndoableEditListener getUndoableEditListener() {
        undoableEditListener.reset();
        return undoableEditListener;
    }

    public UndoActions.RedoAction getRedoAction() {
        return redoAction;
    }

    public UndoActions.UndoAction getUndoAction() {
        return undoAction;
    }

    public static HashMap<JEditorPane, Editor> getEditors() {
        return editors;
    }

    public Container getContainer() {
        return container;
    }

    public List<UserCaretListener> getCaretListeners() {
        return caretListeners;
    }

    public Action getBackupAction() {
        return backupAction;
    }

    public Action getRestoreAction() {
        return restoreAction;
    }

    public JMenuItem getAddStyleSheetMenuItem() {
        return addStyleSheetMenuItem;
    }

    public JButton getBoldButton() {
        return boldButton;
    }

    public JMenuItem getBoldMenuItem() {
        return boldMenuItem;
    }

    public JButton getCodeButton() {
        return codeButton;
    }

    public JButton getCodeSpanButton() {
        return codeSpanButton;
    }

    public JMenuItem getCodeSpanMenuItem() {
        return codeSpanMenuItem;
    }

    public JButton getExitButton() {
        return exitButton;
    }

    public JMenuItem getExitMenuItem() {
        return exitMenuItem;
    }

    public JButton getHeading1Button() {
        return heading1Button;
    }

    public JButton getHeading2Button() {
        return heading2Button;
    }

    public JButton getHyperlinkButton() {
        return hyperlinkButton;
    }

    public JMenuItem getHyperlinkMenuItem() {
        return hyperlinkMenuItem;
    }

    public JButton getImageButton() {
        return imageButton;
    }

    public JMenuItem getImageMenuItem() {
        return imageMenuItem;
    }

    public JMenu getInsertCharacterMenu() {
        return insertCharacterMenu;
    }

    public JButton getItalicButton() {
        return italicButton;
    }

    public JMenuItem getItalicMenuItem() {
        return italicMenuItem;
    }

    public JPanel getjPanel1() {
        return jPanel1;
    }

    public JSeparator getjSeparator1() {
        return separatorFile;
    }

    public JSeparator getjSeparator2() {
        return separatorStructureView;
    }

    public Separator getjSeparator3() {
        return separatorIndent;
    }

    public Separator getjSeparator4() {
        return separatorParagraph;
    }

    public Separator getjSeparator5() {
        return separatorCharacter;
    }

    public Separator getjSeparator6() {
        return separatorStructure;
    }

    public Separator getSeparatorCharacter() {
        return separatorCharacter;
    }

    public Separator getSeparatorFile() {
        return separatorFile;
    }

    public Separator getSeparatorIndent() {
        return separatorIndent;
    }

    public Separator getSeparatorParagraph() {
        return separatorParagraph;
    }

    public Separator getSeparatorStructure() {
        return separatorStructure;
    }

    public JTabbedPane getjTabbedPane1() {
        return jTabbedPane1;
    }

    public ButtonGroup getMainViewButtonGroup() {
        return mainViewButtonGroup;
    }

    public JMenuBar getMenuBar() {
        return menuBar;
    }

    public JMenuItem getOpenFileMenuItem() {
        return openFileMenuItem;
    }

    public JMenuItem getSaveCommentMenuItem() {
        return saveCommentMenuItem;
    }

    public JMenuItem getSaveMenuItem() {
        return saveMenuItem;
    }

    public JButton getSaveServerButton() {
        return saveServerButton;
    }

    public JButton getSaveServerCommentButton() {
        return saveServerCommentButton;
    }

    public JMenuItem getStandardSpanMenuItem() {
        return standardSpanMenuItem;
    }

    public JMenuItem getStylesMenuItem() {
        return stylesMenuItem;
    }

    public JButton getTreeHeadingButton() {
        return treeHeadingButton;
    }

    public JButton getTreeStructureButton() {
        return treeStructureButton;
    }

    public JButton getUnderlineButton() {
        return underlineButton;
    }

    public JMenuItem getUnderlineMenuItem() {
        return underlineMenuItem;
    }
    
    public JPanel getComponentTreePanels() {
        return componentTreePanels;
    }

}
